package cn.catsdad.page;

import cn.catsdad.base.page.PageParam;
import cn.catsdad.util.StringUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.HashMap;
import java.util.Map;

/**
 * 岗位插叙参数
 *
 * @author xuyonglong
 * @version V1.0 2023/4/21
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class PositionParam extends PageParam {

    private Map<String, Object> paramMap = new HashMap<>();

    /**
     * 关键字查询，名称、编码
     */
    private String key;

    @Override
    public Map<String, Object> getParamMap() {
        return this.paramMap;
    }

    @Override
    public String getCondition() {
        StringBuilder condition = new StringBuilder(" and p.isDeleted = 0 ");
        if (StringUtil.isNotEmpty(this.key)) {
            condition.append(" and (p.name like :key or p.code like :key)");
            this.paramMap.put("key", likeQuery(this.key));
        }
        return condition.toString();
    }
}
